//
//  BBSimpleObjectServer.h
//  BBTouch
//
//  Created by ben smith on 7/29/08.
//  This file is part of BBTouch.
//
//  BBTouch is free software: you can redistribute it and/or modify
//  it under the terms of the GNU Lesser General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.

//  BBTouch is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Lesser General Public License for more details.

//  You should have received a copy of the GNU Lesser General Public License
//  along with BBTouch.  If not, see <http://www.gnu.org/licenses/>.
// 
//  Copyright 2008 Ben Britten Smith ben@benbritten.com .
//

#import <Cocoa/Cocoa.h>

// this is a simple class that implements a distributed object server
// the objects that we will be serving are going to be simple NSDictionaries

// NOTE: this object is not finished, not tested, not nuthin

@protocol BBSimpleObjectClientProtocol
- (BOOL) sendMessageToClient:( in bycopy NSDictionary *)msg; 
@end

@protocol BBSimpleObjectServerProtocol
- (BOOL) sendMessageToServer:(bycopy NSString *)msg;
- (BOOL) registerClient: (byref id)client withName:(bycopy NSString *) name;
- (BOOL) unregisterClientWithName: (bycopy NSString *) name;
@end



@interface BBSimpleObjectServer : NSObject <BBSimpleObjectServerProtocol> {
	NSMutableArray * clients;
	NSConnection * connection; 
}


+ (BBSimpleObjectServer*)defaultServerOnPort:(int)portnum;
- (BOOL) registerClient: (byref id)client withName:(bycopy NSString *) name;
- (BOOL) sendMessageToServer:(bycopy NSString *)msg;
- (BOOL) unregisterClientWithName: (bycopy NSString *) name;
- (void) connectionDidDie:(id)val ;;
- (void) connectionInitialized:(id)val;;
- (void)startListeningOnPort:(int)portnum;

// 7 methods

@end
